-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat auth supported for clients #111
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #111 +/- ##
=========================================
- Coverage 49.47% 49.27% -0.2%
=========================================
Files 62 62
Lines 6280 6307 +27
=========================================
+ Hits 3107 3108 +1
- Misses 2826 2849 +23
- Partials 347 350 +3
Continue to review full report at Codecov.
|
@@ -168,6 +169,13 @@ func (r *Request) IsSupport() bool { | |||
return ok | |||
} | |||
|
|||
func (r *Request) IsAuth() bool { | |||
if r.IsCtl() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return r.IsCtrl() && bytes.Equal(r.resp.array[0].data, cmdAuthBytes)
} else if bytes.Equal(reqData, cmdQuitBytes) { | ||
req.reply.respType = respString | ||
// general supported cmd need authorized | ||
if !pc.authorized && !req.IsAuth() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not forward any command when pc.authorized
is false. And so that authorized should be atomic flag or guard by mutex (be used by encoder/decoder together).
proxy supported AUTH cmd for clients